﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	    : FI.Net Application Framework
// COMPONENT ID	    : FI.Core
// COMPONENT DESC   : FI.Net Core Foundation
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

using FI.Core.Utilities;
using System.Runtime.Serialization;

namespace FI.Core
{
    /// <summary>
    /// Error information for validation.
    /// </summary>
    [DataContract(Namespace = Constants.Namespace)]
    public  class ValidationError
    {
        #region Fields
        [DataMember(Name ="Key")]
        private string key;
        [DataMember(Name = "Message")]
        private string message;
        [DataMember(Name = "Tag")]
        private string tag;
        #endregion

        #region Properties

        /// <summary>
        /// Get or set a name describing the location of the validation result.
        /// </summary>
        /// <value>
        /// The name describing the location of the validation result.
        /// </value>
        public string Key
        {
            get { return key; }
            set { key = value; }
        }


        /// <summary>
        /// Get a message describing the validation failure.
        /// </summary>
        /// <value>
        /// The message describing the validation failure.
        /// </value>
        public string Message
        {
            get { return message; }
        }

        /// <summary>
        /// Get or set a value characterizing the fault.
        /// </summary>
        /// <value>
        /// The value characterizing the fault.
        /// </value>
        /// <remarks>
        /// The meaning for a tag is determined by the client code consuming the <see cref="ValidationError" />.
        /// </remarks>
        public string Tag
        {
            get { return tag; }
            set { tag = value; }
        }
        #endregion

        #region Constructors

        /// <summary>
        /// Construct a new <see cref="ValidationError"/> object with the given values.
        /// </summary>
        /// <param name="message">Message about validation failure.</param>
        /// <param name="key">Name describing the location of the validation result.</param>
        /// <param name="tag">Get a value characterizing the result.</param>
        public ValidationError(string key, string message, string tag)
        {
            Guard.ArgumentNotNullOrEmpty(message, "message");

            this.key = key;
            this.message = message;
            this.tag = tag;
        }
        #endregion
    }
}
